package com.zlzlib.mybatis;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;

/**
 * //@Configuration
 *
 * @DateTime: 2023/5/4 16:24
 * @Author zlz
 * @Version 1.0
 */
public abstract class BaseMyBatisPlusConfig {

    @Bean
    public MybatisPlusInterceptor paginationInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加MySQL的分页拦截器
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        initInterceptor(interceptor);
        return interceptor;
    }

    /**
     * 设置拦截器
     *
     * @param interceptor 拦截器
     */
    protected abstract void initInterceptor(MybatisPlusInterceptor interceptor);

}
